import pandas as pd#读取数据库文件
import numpy as np
from sklearn.model_selection import train_test_split#划分数据集
from sklearn.tree import DecisionTreeClassifier#决策树
from sklearn.linear_model import LogisticRegression#逻辑回归
from sklearn.neighbors import KNeighborsClassifier#K近邻
from sklearn import svm#支持向量机
from sklearn.metrics import classification_report#分类报告

#1.读取数据
data = pd.read_csv("data.csv",header=0)
x = data.drop(columns='Label')
y = data['Label']

#2.划分数据集
x_train,x_test,y_train,y_test=train_test_split(x,y)

#3.模型训练     逻辑回归    支持向量机  K近邻   决策树
clfs = [LogisticRegression(), svm.SVC(), KNeighborsClassifier(), DecisionTreeClassifier()]
for clf in clfs:
    print(clf)
    clf.fit(x_train,y_train)
    
#4.测试
    predict=clf.predict(x_test)

#5.输出结果及分析
    print(classification_report(y_test,predict))
